﻿#region Copyright information
// 
// Copyright © 2005-2013 Yongkee Cho. All rights reserved.
// 
// This code is a part of the Biological Object Library and governed under the terms of the
// GNU Lesser General  Public License (LGPL) version 2.1 which accompanies this distribution.
// For more information on the LGPL, please visit http://bol.codeplex.com/license.
// 
// - Filename: IGenome.cs
// - Author: Yongkee Cho
// - Email: yongkeecho@gmail.com
// - Date Created: 2012-12-08 8:26 AM
// - Last Modified: 2013-01-25 3:59 PM
// 
#endregion
using System;
using BOL.Algorithms.Graph;
using BOL.Algorithms.Tree;

namespace BOL.Algorithms.Optimization.EvolutionaryAlgorithms
{
    public interface IGenome<TGene> : IComparable, ICloneable, IComparable<IGenome<TGene>>
    {
        /// <sumary>Gets the fitness of sequence.</sumary>
        double Fitness { get; set; }

        /// <sumary>Evaluates the fitness of sequence.</sumary>
        void Evaluate();

        /// <sumary>Gets a random genome.</sumary>
        IGenome<TGene> Offspring();

        /// <sumary>Recombinates two sequences.</sumary>
        void Crossover(IGenome<TGene> other);

        /// <sumary>Mutates the sequence with a given rate.</sumary>
        void Mutate(double mutationRate);
    }

    public interface ILamarckianGenome<TGene, TPhenome> : IGenome<TGene>
    {
        void Optimize();
    }

    public interface IArrayGenome<TGene> : IGenome<TGene>, IEquatable<IArrayGenome<TGene>>
    {
        /// <sumary>Gets or sets the genome sequence.</sumary>
        TGene[] Sequence { get; set; }

        /// <sumary>Gets the length of sequence.</sumary>
        int Length { get; }
    }

    public interface ILamarckianArrayGenome<TGene, TPhenome> : IArrayGenome<TGene>, ILamarckianGenome<TGene, TPhenome>
    {
    }

    public interface IGraphGenome<TGene> : IGenome<TGene>, IEquatable<IGraphGenome<TGene>>
    {
        /// <sumary>Gets or sets the genome graph.</sumary>
        IGraph Graph { get; set; }

        /// <sumary>Gets the length of sequence.</sumary>
        int Order { get; }

        /// <sumary>Gets the length of sequence.</sumary>
        int Size { get; }
    }

    public interface ILamarckianGraphGenome<TGene, TPhenome> : IGraphGenome<TGene>, ILamarckianGenome<TGene, TPhenome>
    {
    }

    public interface ITreeGenome<TGene> : IGenome<TGene>, IEquatable<ITreeGenome<TGene>>
    {
        /// <sumary>Gets or sets the genome tree.</sumary>
        ITreeNode<TGene> RootNode { get; set; }

        /// <sumary>Gets the number of nodes in a tree.</sumary>
        int Count { get; }
    }

    public interface ILamarckianTreeGenome<TGene, TPhenome> : ITreeGenome<TGene>, ILamarckianGenome<TGene, TPhenome>
    {
    }
}
